<!DOCTYPE html>
<html lang="zh">
<head>
    <!--解决不同服务器图片跨域访问问题-->
    <meta name="referrer" content="no-referrer"/>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="./js/jquery-3.1.1.js"></script>
    <link rel="stylesheet" href="./css/搜索框.css">
    <link rel="stylesheet" href="css/index.css">
    <title>星龙小说网</title></head>
</head>
<body>
<!--头部-->
<header>
    <h1>星龙小说网</h1>
</header>
<!--导航栏-->
<nav class="navbar">
    <ul>
        <li><a href="/index.html">首页</a></li>
        <li><a href="/Allnovels.html">全部小说</a></li>
        <li><a href="/about.html">关于我们</a></li>
        <li><a href="/user.html">个人信息</a></li>
        <li><a href="BookCar.html">我的书架</a></li>
    </ul>
    <span class="userinfo">用户名：<span id="name"></span>&nbsp;<a href="http://localhost:8080/loginOut">注销</a></span>
    <span class="gotologin">请先<a href="login.html">登录</a></span>
</nav>
<!--高分推荐-->
<div id="title">
    <h1 style="width: 400px">高分电影小说推荐</h1>
    <label>
        <input  type="text" placeholder="搜索想看的小说">
    </label>
    <button id ="search">搜索</button>
</div>
<!--分割-->
<div id="fg"></div>
<!--内容-->
<div class="container">
    <div class="left">
        <div class="row">
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
        </div>
        <div class="row">
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
        </div>
        <div class="row">
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
            <div class="column">
                <li><p class="titles"></p>
                    <img class="Mimg" src="">
                </li>
            </div>
        </div>
    </div>
    <div class="right">
        <h2>小说资讯快报</h2>
        <ul class="popular">
            <li><a href="https://www.shu18.cc/2033/">将门闺秀----</a><a href="https://www.shu18.cc/author/一泓喜悲/" class="author">作者：一泓喜悲</a></li><br>
            <li><a href="https://www.shu18.cc/2133/">小咲良是男装大佬[综]----</a><a href="https://www.shu18.cc/author/零坂青花/" class="author">作者：零坂青花</a></li><br>
            <li><a href="https://www.shu18.cc/2233/">婚色撩人：总裁缠不休----</a><a href="https://www.shu18.cc/author/双凝/" class="author">作者：双凝</a></li><br>
            <li><a href="https://www.shu18.cc/2333/">情深似浅----</a><a href="https://www.shu18.cc/author/蔚空/" class="author">作者：蔚空</a></li><br>
            <li><a href="https://www.shu18.cc/2433/">盛装只为错过你----</a><a href="https://www.shu18.cc/author/孤烟/" class="author">作者：孤烟</a></li><br>
            <li><a href="https://www.shu18.cc/2533/">六零年代继母养儿手札----</a><a href="https://www.shu18.cc/author/叶逐月/" class="author">作者：叶逐月</a></li><br>
            <li><a href="https://www.shu18.cc/2633/">快穿女主：高冷男神，撩个够！----</a><a href="https://www.shu18.cc/author/初子鱼/" class="author">作者：初子鱼</a></li><br>
            <li><a href="https://www.shu18.cc/2733/">临南----</a><a href="https://www.shu18.cc/author/天如玉/" class="author">作者：天如玉</a></li><br>
            <li><a href="https://www.shu18.cc/2833/">傅少的心尖宠妻----</a><a href="https://www.shu18.cc/author/莲夕/" class="author">作者：莲夕</a></li><br>
            <li><a href="https://www.shu18.cc/2933/">许君朝朝暮暮----</a><a href="https://www.shu18.cc    /author/白骨生花/" class="author">作者：白骨生花</a></li></ul><br>
        </ul>
    </div>
</div>
<!--底部-->
<div class="button">
    <a style="margin:40px 0 30px 0" href="#" id="goTop" >>>返回顶部<<</a>
</div>

<div class="pageContainer">
    <p >本站所有小说为转载作品，转载至本站只是为了宣传更多优质小说供观众佬爷们欣赏。</p>
    <p>Copyright 2024 <a href="https://www.shu18.cc/top/">第一版主小说网</a> All Rights Reserved.</p>
</div>

</body>
<script>
    $(document).ready(function () {
        getuser();
        showinfo();
    });


    function getuser() {
        $.get("http://localhost:8080/getUser", null, function (data) {
            console.log(data);
            if (data === "") {
                $(".gotologin").show();  // 显示
                $(".userinfo").hide();   // 隐藏
            } else {
                $(".gotologin").hide();
                $(".userinfo").show()
                $("#name").text(data.nikename);
            }
        });
    }

    function showinfo() {
        $.get("http://localhost:8080/getTop12Book", null, function (data) {
            console.log(data); // 打印整个数据数组
            for (var i = 0; i < data.length; i++) {
                console.log("Title:", data[i].bname);
                console.log("ID:", data[i].bid);
                console.log("Book URL:", data[i].bimg);


                // 确保data[i].detailUrl存在,否则填充默认值
                var detailUrl = data[i].detailUrl == null ? "http://localhost:8080/Loading.html" : data[i].detailUrl;
                $(".titles").eq(i).text(data[i].bname);
                $(".Mimg").eq(i).attr("src", data[i].bimg);
                $(".Mimg").eq(i).attr("bid", data[i].bid);
                // $(".column a").eq(i).attr("href", detailUrl);
            }
        });
    }

    $(".Mimg").click(function (){
        var bid = $(this).attr("bid")
        // alert(bid);
        sessionStorage.setItem("bid",bid);
        location.href="/novelinfo.html"
    })
</script>

</html>